<!--  -->
<template>
    <div class="app-container">
        <el-form :inline="true" size="small">
            <el-form-item label="账号编号">
                <el-input v-model="mId" placeholder="请输入账号编号" size="small"></el-input>
            </el-form-item>
            <el-form-item label="账号名称">
                <el-input v-model="mName" placeholder="请输入账号名称" size="small"></el-input>
            </el-form-item>
            <el-form-item label="状态">
                <el-select v-model="status" placeholder="角色状态" clearable filterable @change>
                    <el-option label="正常" value="normal"></el-option>
                    <el-option label="停用" value="stop"></el-option>
                </el-select>
            </el-form-item>

            <el-button icon="el-icon-search" type="primary" size="small" @click>搜索</el-button>
            <el-button icon="el-icon-refresh" size="small" @click>重置</el-button>
            <el-button icon="el-icon-edit" type="warning" size="small" @click="add">新增</el-button>
            <el-button icon="el-icon-delete" type="danger" size="small" @click>删除</el-button>

            <el-button class="ref-btn" icon="el-icon-refresh" circle @click></el-button>
        </el-form>
        <el-table :data="tableData" border stripe>
            <el-table-column type="selection" width="60" align="center"></el-table-column>

            <template v-for="(i, index) in columns">
                <el-table-column
                    v-if="index == 3"
                    :key="i.id"
                    :label="i.label"
                    align="center"
                    :width="i.width"
                >
                    <template slot-scope="scope">
                        <el-switch
                            v-model="scope.row.logId"
                            :active-value="1"
                            :inactive-value="2"
                            @change
                        ></el-switch>
                    </template>
                </el-table-column>

                <el-table-column
                    v-else
                    :prop="i.data"
                    :key="i.id"
                    :label="i.label"
                    align="center"
                    :width="i.width"
                />
            </template>
            <el-table-column align="center" label="操作">
                <template slot-scope="scope">
                    <el-button type="text" @click="edit(scope.row)">编辑</el-button>
                    <el-button type="text" @click="cPwd(scope.row)">修改密码</el-button>

                    <el-button type="text" @click="del(scope.$index, scope.row)">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
        <!-- 分页 -->
        <div class="page">
            <el-pagination
                @size-change="sizeChange"
                @current-change="currentChange"
                :current-page.sync="page"
                :page-sizes="[20, 40, 80, 100]"
                :page-size="limit"
                layout="total, sizes, prev, pager, next, jumper"
                :total="total"
                background
            ></el-pagination>
        </div>

        <!-- 编辑 -->
        <el-dialog
            :title="dialogTitle"
            :visible.sync="showDialog"
            width="30%"
            @close="showDialog = false"
        >
            <el-form v-model="form" label-width="120px" :inline="false" size="normal">
                <el-form-item label="账号编号">
                    <el-input
                        v-model="form.id"
                        placeholder="请填写账号编号"
                        style="width: 220px"
                    ></el-input>
                </el-form-item>
                <el-form-item label="账号名称">
                    <el-input
                        v-model="form.name"
                        placeholder="请填写账号名称"
                        style="width: 220px"
                    ></el-input>
                </el-form-item>
                <el-form-item label="登录ID">
                    <el-input
                        v-model="form.logId"
                        placeholder="请填写登录ID"
                        style="width: 220px"
                    ></el-input>
                </el-form-item>
                <el-form-item label="状态">
                    <el-switch
                        v-model="form.status"
                        :active-value="1"
                        :inactive-value="2"
                        @change=""
                    >
                    </el-switch>
                </el-form-item>
            </el-form>
            <span slot="footer">
                <el-button @click="showDialog = false">取消</el-button>
                <el-button type="primary" @click>确定</el-button>
            </span>
        </el-dialog>
        <el-dialog title="修改密码" :visible.sync="showPwd" width="30%" @close="">
            <el-form v-model="form" label-width="120px" :inline="false" size="normal">
                <el-form-item label="新密码">
                    <el-input
                        v-model="form.subname"
                        placeholder="请输入新密码"
                        style="width: 220px"
                    ></el-input>
                </el-form-item>
                <el-form-item label="确认密码">
                    <el-input
                        v-model="form.subname"
                        placeholder="请确认密码"
                        style="width: 220px"
                    ></el-input>
                </el-form-item>
            </el-form>
            <span slot="footer">
                <el-button @click="showPwd = false">Cancel</el-button>
                <el-button type="primary" @click="">OK</el-button>
            </span>
        </el-dialog>
    </div>
</template>

<script>
import { getArticle } from "@/api/article";
export default {
    name: "slider",
    data () {
        return {
            mId: "",
            mName: "",
            status: "",
            keyword: "",
            showPwd: false,
            page: 1,
            limit: 11,
            total: 10,
            dialogTitle: "创建",
            showDialog: false,
            form: {
                subTime: "",
                subname: "",
                sustatus: "",
                sublogId: "",
            },
            options: [
                {
                    value: 1,
                    label: "支付方式1",
                },
                {
                    value: 2,
                    label: "支付方式2",
                },
            ],
            tableData: [
                {
                    id: "1",
                    bTime: "2021-02-21",
                    name: "生日模板",
                    logId: 1,
                    status: 20,
                },
                {
                    id: "2",
                    bTime: "2021-02-21",
                    name: "生日模板",
                    logId: 2,
                    status: 30,
                },
                {
                    id: "3",
                    bTime: "2021-02-21",
                    name: "生日模板",
                    logId: 1,
                    status: 40,
                },
            ],

            columns: [
                { key: 0, label: `账号编号`, data: "id", visible: true, width: "80" },
                { key: 1, label: `账号名称`, data: "name", visible: true },
                { key: 2, label: `登录ID`, data: "logId", visible: true },
                { key: 3, label: `状态`, data: "flag", visible: true },
                { key: 4, label: `创建时间`, data: "bTime", visible: true },
            ],
            artQuery: {
                id: "1",
            },
        };
    },
    created () { },
    methods: {
        add () {
            this.dialogTitle = "新建";
            this.showDialog = true;
        },
        edit () {
            this.dialogTitle = "编辑";
            this.showDialog = true;
        },
        cPwd () {
            this.showPwd = true;
        },
        del () {
            this.$confirm("确认删除所选数据？", "确认删除", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
                center: true,
            })
                .then(() => {
                    this.$message.warning("删除成功！");
                    this.tableData.splice(i, 1);
                })
                .catch(() => { });
        },
        save () {
            this.$message.success("保存成功！");
        },
        refresh () {
            this.$message.success("重置成功！");
        },
        sizeChange () { },
        beforeCoverUpload () { },
        currentChange () { },
    },
};
</script>
<style scoped>
.slideImg {
    width: 140px;
}
</style>
